package com.ky.facescan.utils;


import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;

import com.ky.facescan.base.BaseApp;


/**
 * 提示类
 */

public class ToastUtils {
    private static Toast toast;//在类前面声明吐司，确保在这个页面只有一个吐司

    public static void show(String msg) {
        new Handler(Looper.getMainLooper()).post(() -> {
            if (toast != null) {
                toast.cancel();//关闭吐司显示
                toast = null;
            }
            toast = Toast.makeText(BaseApp.app, msg, Toast.LENGTH_SHORT);
            toast.show();//重新显示吐司
        });

    }
}
